#ifndef XGSINGLETON_H
#define XGSINGLETON_H

#define xg_init_singleton(a) a* XgSingleton<a>::_instance = 0;

template< class C >
class XgSingleton
{
public:
	static C* Current()
	{
		if( _instance == 0 )
		{
			_instance = new C;
		}
		return _instance;
	}

	static void Destroy()
	{
		if( _instance != 0 )
		{
			delete _instance;
			_instance = 0;
		}
	}

protected:
	static C* _instance;
};

#endif //XGSINGLETON_H